import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

// 可以写在外边，也可以写在Vuex.Store里边
const state = {
    // 存储token
    Authorization: localStorage.getItem('Authorization') ? localStorage.getItem('Authorization') : '',
    aa: '123'
}

const token = new Vuex.Store({
    state,
    getters:{
        projectNameResult(state){
          return state.aa;
        },
        getToken(state){
            return state.Authorization;
        }
    },
    mutations: {
        // 修改token，并将token存入localStorage
        changeLogin (state, token) {
            state.Authorization = token;
            localStorage.setItem('Authorization', token);
        }
    },
    actions: {
        
    },
    modules: {
    }
});

export default token;